//===================================================================================
// $$
//
// Coder: Code Milker v1.0
// 0 - EntityName
// 1 - Properties
//===================================================================================


namespace App.Domain.Handlers {
    using System;
    using App.Data;
    using App.Domain.Contracts;
    using App.Domain.Models;

    public class CreateEducation {
        private readonly IEducationRepository _educationRepository;

        public CreateEducation(IEducationRepository educationRepository) {
            _educationRepository = educationRepository;
        }

        public void Execute(Guid userId, ICreateEducationCommand educationForm) {
            if (educationForm == null)
                throw new ArgumentNullException("educationForm");

            try {
                var education = educationForm.ConvertToEntity();
                _educationRepository.Create(education);
            }
            catch (InvalidOperationException ex) {
                throw new BusinessServicesException("UnableToCreateVehicleExceptionMessage", ex);
            }
        }
    }
}
